// Live

function stripeTables() {
  var tables = document.getElementsByTagName("table");

  for (var i = 0; i < tables.length; i++) {
    var rows = tables[i].getElementsByTagName("tr");
    for (var j = 0; j < rows.length; j++) {
      if (j % 2 == 0) {
        addClass(rows[j], "odd");
      }
    }
  }
}


function highlightRows() {
  var rows = document.getElementsByTagName("tr");

  for (var i = 0; i < rows.length; i++) {
    rows[i].oldClassName = rows[i].className;
    rows[i].onmouseover = function() {
      addClass(this, "highlight");
    }
    rows[i].onmouseout = function() {
      this.className = this.oldClassName;
    }
  }
}


function displayAbbreviations() {
  var abbrs = document.getElementsByTagName("abbr");

  var defines = new Array();
  for (var i = 0; i < abbrs.length; i++) {
    var key = abbrs[i].lastChild.nodeValue;
    defines[key] = abbrs[i].getAttribute("title");
  }

  var list = document.createElement("dl");
  for (key in defines) {
    var title = document.createElement("dt");
    title.appendChild(document.createTextNode(key));
    var define = document.createElement("dd");
    define.appendChild(document.createTextNode(defines[key]));

    list.appendChild(title);
    list.appendChild(define);
  }

  var header = document.createElement("h3");
  header.appendChild(document.createTextNode("Abbreviations"));

  var article = document.getElementById("main");
  article.appendChild(header);
  article.appendChild(list);
}


addLoadEvent(stripeTables);
addLoadEvent(highlightRows);
addLoadEvent(displayAbbreviations);
